import request from "@/utils/request";
import { AxiosPromise } from 'axios';
import { AllocationForm, AllocationQuery } from '@/api/collect/allocation/types';
import { PropertyForm, PropertyQuery, PropertyVO } from '@/api/collect/execute/property/types';

/**
 * 查询资产类数据列表
 * @param query
 * @returns
 */

export const listProperty = (query?: PropertyQuery) => {
  return request({
    url: "/collect/property/list",
    method: "post",
    data: query
  });
};

/**
 * 查询资产类数据总额
 * @param query
 * @returns
 */

export const totalProperty = (query?: PropertyQuery) => {
  return request({
    url: "/collect/property/getTotal",
    method: "post",
    data: query
  });
};

/**
 * 分配数据（资产类数据）
 * @param dto
 */
export const allocation = (dto: AllocationForm) => {
  return request({
    url: "/collect/property/allot",
    method: "post",
    data: dto
  });
};
/**
 * 撤销数据分配（资产类数据）
 * @param id
 */
export const withdraw = (id: string | number) => {
  return request({
    url: "/collect/property/withdraw/" + id,
    method: "get",
    params: id
  });
};
/**
 * 查询资产类数据详细
 * @param id
 */
export const getProperty = (id: string | number): AxiosPromise<PropertyVO> => {
  return request({
    url: '/collect/property/' + id,
    method: 'get'
  });
};
/**
 * 新增资产类数据
 * @param data
 */
export const addProperty = (data: PropertyForm) => {
  return request({
    url: '/collect/property/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改资产类数据
 * @param data
 */
export const updateProperty = (data: PropertyForm) => {
  return request({
    url: '/collect/property/edit',
    method: 'put',
    data: data
  });
};

/**
 * 删除资产类数据
 * @param id
 */
export const delProperty = (id: string | number | Array<string | number>) => {
  return request({
    url: '/collect/property/' + id,
    method: 'delete'
  });
};




